package com.qiyang.login.service.impl;

import com.qiyang.login.dao.entity.SysUser;
import com.qiyang.login.dao.SysUserRepository;
import com.qiyang.login.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created on 2018/5/3.
 *
 * @author sehuaqi.
 * 描述：业务逻辑层
 */
@Service
public class LoginServiceImpl implements LoginService {

    @Autowired
    private SysUserRepository sysUserRepository;

    /**
     * 处理用户登录业务逻辑
     * @param username
     * @param password
     * @return
     */
    @Override
    public SysUser login(String username, String password) {

        //SysUser sysUser = sysUserRepository.findByUserName(username);
        SysUser sysUser = new SysUser();
        sysUser.setUserName(username);
        sysUser.setPwd(password);
        sysUser.setNickname("管理员");
        sysUser.setId(1020036L);

//        var i = 0;

//        byte short int long float char  double boolean  string

        if (sysUser != null) {
            //验证密码的逻辑省略
            if(!sysUser.getPwd().equals(password)){
                return null;
            }
        }

        return sysUser;
    }

}
